<?php

namespace app\common\model;

use think\Exception;
use think\Model;

class UserModel extends Model
{
    //
    public
        $table = 'cms_blog_admin',
        $pk = 'id';

    public function updateData($param)
    {
        try {
            $rund = rand(6, 16);
            $encrypt = (new CommonModel())->getRandStr($rund);
            $data = [
                'username' => $param['username'],
                'group_id' => $param['group_id'],
                'name' => $param['name'],
                'password' => $encrypt,
                'create_time' => time(),
            ];
            $sql = $this->save($data);
            if ($sql) {
                $decrypt = (new CommonModel())->thinkDecrypt($encrypt);
                $message = '添加成功,密码:' . $decrypt;
                return ['status' => 1, 'message' => $message];
            } else {
                return ['status' => 0, 'message' => '添加失败'];
            }
        } catch (\Exception $e) {
            echo $e->getMessage() . '.........' . $e->getLine();
        }
    }




}
